package paneles;

import java.awt.FlowLayout;

import javax.swing.BorderFactory;
import javax.swing.JButton;
import javax.swing.JFrame;
import javax.swing.JLabel;
import javax.swing.JTextField;
import javax.swing.SwingConstants;
import javax.swing.WindowConstants;
import javax.swing.border.LineBorder;

import datos.Proveedor;

/**
* This code was edited or generated using CloudGarden's Jigloo
* SWT/Swing GUI Builder, which is free for non-commercial
* use. If Jigloo is being used commercially (ie, by a corporation,
* company or business for any purpose whatever) then you
* should purchase a license for each developer using Jigloo.
* Please visit www.cloudgarden.com for details.
* Use of Jigloo implies acceptance of these licensing terms.
* A COMMERCIAL LICENSE HAS NOT BEEN PURCHASED FOR
* THIS MACHINE, SO JIGLOO OR THIS CODE CANNOT BE USED
* LEGALLY FOR ANY CORPORATE OR COMMERCIAL PURPOSE.
*/
public class PanelProveedores extends javax.swing.JPanel {
	private JLabel lNombre;
	private JTextField tNombre;
	private JTextField tCelular;
	private JLabel lCelular;
	private JButton bCancelar;
	private JButton bAceptar;
	private JTextField tWeb;
	private JTextField tEmail;
	private JTextField tTelefono;
	private JTextField tCp;
	private JTextField tCiudad;
	private JTextField tDireccion;
	private JLabel lCp;
	private JLabel lCiudad;
	private JLabel lWeb;
	private JLabel lEmail;
	private JLabel lTelefono;
	private JLabel lDireccion;

	/**
	* Auto-generated main method to display this 
	* JPanel inside a new JFrame.
	*/
	public static void main(String[] args) {
		JFrame frame = new JFrame();
		frame.getContentPane().add(new PanelProveedores());
		frame.setDefaultCloseOperation(WindowConstants.DISPOSE_ON_CLOSE);
		frame.pack();
		frame.setVisible(true);
	}
	
	public PanelProveedores() {
		super();
		initGUI();
	}
	
	private void initGUI() {
		try {
			FlowLayout thisLayout = new FlowLayout();
			thisLayout.setHgap(10);
			thisLayout.setVgap(10);
			this.setLayout(thisLayout);
			this.setPreferredSize(new java.awt.Dimension(285, 292));
			//this.setBackground(new java.awt.Color(0,0,0));
			{
				lNombre = new JLabel();
				this.add(lNombre);
				lNombre.setText("Nombre");
				lNombre.setBorder(new LineBorder(new java.awt.Color(0,0,0), 1, false));
				lNombre.setPreferredSize(new java.awt.Dimension(80, 21));
				lNombre.setHorizontalAlignment(SwingConstants.CENTER);
				lNombre.setForeground(new java.awt.Color(0,0,0));
			}
			{
				tNombre = new JTextField();
				this.add(tNombre);
				tNombre.setPreferredSize(new java.awt.Dimension(150, 21));
				tNombre.setBorder(new LineBorder(new java.awt.Color(0,0,0), 1, false));
			}
			{
				lDireccion = new JLabel();
				this.add(lDireccion);
				lDireccion.setText("Direccion");
				lDireccion.setBorder(new LineBorder(new java.awt.Color(0,0,0), 1, false));
				lDireccion.setPreferredSize(new java.awt.Dimension(80, 21));
				lDireccion.setHorizontalAlignment(SwingConstants.CENTER);
				//lDireccion.setForeground(new java.awt.Color(255,128,0));
			}
			{
				tDireccion = new JTextField();
				this.add(tDireccion);
				tDireccion.setPreferredSize(new java.awt.Dimension(150, 21));
				tDireccion.setBorder(new LineBorder(new java.awt.Color(0,0,0), 1, false));
			}
			{
				lCiudad = new JLabel();
				this.add(lCiudad);
				lCiudad.setText("Ciudad");
				lCiudad.setBorder(new LineBorder(new java.awt.Color(0,0,0), 1, false));
				lCiudad.setPreferredSize(new java.awt.Dimension(80, 21));
				lCiudad.setHorizontalAlignment(SwingConstants.CENTER);
			}
			{
				tCiudad = new JTextField();
				this.add(tCiudad);
				tCiudad.setPreferredSize(new java.awt.Dimension(150, 21));
				tCiudad.setBorder(new LineBorder(new java.awt.Color(0,0,0), 1, false));
			}
			{
				lCp = new JLabel();
				this.add(lCp);
				lCp.setText("Cod. Postal");
				lCp.setBorder(new LineBorder(new java.awt.Color(0,0,0), 1, false));
				lCp.setPreferredSize(new java.awt.Dimension(80, 21));
				lCp.setHorizontalAlignment(SwingConstants.CENTER);
				lCp.setForeground(new java.awt.Color(0,0,0));
			}
			{
				tCp = new JTextField();
				this.add(tCp);
				tCp.setPreferredSize(new java.awt.Dimension(150, 21));
				tCp.setBorder(new LineBorder(new java.awt.Color(0,0,0), 1, false));
			}
			{
				lTelefono = new JLabel();
				this.add(lTelefono);
				lTelefono.setText("Telefono");
				lTelefono.setBorder(new LineBorder(new java.awt.Color(0,0,0), 1, false));
				lTelefono.setPreferredSize(new java.awt.Dimension(80, 21));
				lTelefono.setHorizontalAlignment(SwingConstants.CENTER);
			}
			{
				tTelefono = new JTextField();
				this.add(tTelefono);
				tTelefono.setPreferredSize(new java.awt.Dimension(150, 21));
				tTelefono.setBorder(new LineBorder(new java.awt.Color(0,0,0), 1, false));
			}
			{
				lCelular = new JLabel();
				this.add(lCelular);
				lCelular.setText("Celular");
				lCelular.setHorizontalAlignment(SwingConstants.CENTER);
				lCelular.setPreferredSize(new java.awt.Dimension(80,21));
				lCelular.setBorder(new LineBorder(new java.awt.Color(0,0,0), 1, false));
				//lCelular.setForeground(new java.awt.Color(255,128,0));
			}
			{
				tCelular = new JTextField();
				this.add(tCelular);
				tCelular.setPreferredSize(new java.awt.Dimension(150,21));
				tCelular.setBorder(new LineBorder(new java.awt.Color(0,0,0), 1, false));
			}
			{
				lEmail = new JLabel();
				this.add(lEmail);
				lEmail.setText("Email");
				lEmail.setBorder(new LineBorder(new java.awt.Color(0,0,0), 1, false));
				lEmail.setPreferredSize(new java.awt.Dimension(80, 21));
				lEmail.setHorizontalAlignment(SwingConstants.CENTER);
			}
			{
				tEmail = new JTextField();
				this.add(tEmail);
				tEmail.setPreferredSize(new java.awt.Dimension(150, 21));
				tEmail.setBorder(new LineBorder(new java.awt.Color(0,0,0), 1, false));
			}
			{
				lWeb = new JLabel();
				this.add(lWeb);
				lWeb.setText("Web");
				lWeb.setBorder(new LineBorder(new java.awt.Color(0,0,0), 1, false));
				lWeb.setPreferredSize(new java.awt.Dimension(80, 21));
				lWeb.setHorizontalAlignment(SwingConstants.CENTER);
				//lWeb.setForeground(new java.awt.Color(255,128,0));
			}
			{
				tWeb = new JTextField();
				this.add(tWeb);
				tWeb.setPreferredSize(new java.awt.Dimension(150, 21));
				tWeb.setBorder(new LineBorder(new java.awt.Color(0,0,0), 1, false));
			}
			{
				bAceptar = new JButton();
				this.add(bAceptar);
				bAceptar.setText("Aceptar");
				bAceptar.setPreferredSize(new java.awt.Dimension(100, 25));
				//bAceptar.setBackground(new java.awt.Color(255,128,0));
			}
			{
				bCancelar = new JButton();
				this.add(bCancelar);
				bCancelar.setText("Cancelar");
				bCancelar.setPreferredSize(new java.awt.Dimension(100, 25));
				//bCancelar.setBackground(new java.awt.Color(255,128,0));
			}
		} catch (Exception e) {
			e.printStackTrace();
		}
	}
	
	public void setProveedor(Proveedor p){
		this.tNombre.setText(p.getNombre());
		this.tDireccion.setText(p.getDireccion());
		this.tCiudad.setText(p.getCiudad());
		if (p.getCp()!=null)
			this.tCp.setText(p.getCp().toString());
		else
			this.tCp.setText("");
		this.tTelefono.setText(p.getTelefono().toString());
		this.tCelular.setText(p.getCelular().toString());
		this.tEmail.setText(p.getEmail());
		this.tWeb.setText(p.getWeb());
	}

	public JButton getBCancelar() {
		return bCancelar;
	}

	public JButton getBAceptar() {
		return bAceptar;
	}

	public Proveedor getProveedor() {
		Proveedor p = new Proveedor();
		p.setCelular(this.tCelular.getText());
		p.setCiudad(this.tCiudad.getText());
		if (this.tCp.getText().equals(""))
			p.setCp(null);
		else
			p.setCp(Integer.valueOf(this.tCp.getText()));
		p.setDireccion(this.tDireccion.getText());
		p.setEmail(this.tEmail.getText());
		p.setNombre(this.tNombre.getText());
		p.setTelefono(this.tTelefono.getText());
		p.setWeb(this.tWeb.getText());
		return p;
	}

}
